let VehicleFactory = function (subType, superType) {
    if(typeof VehicleFactory[superType] === 'function') {
        function F() {}
        F.prototype = new VehicleFactory[superType]();
        subType.constructor = subType;
        subType.prototype = new F();
    } else {
        throw new Error('未创建该抽象类');
    }
};
VehicleFactory.Car = function () {
    this.type = 'car';
};
VehicleFactory.Car.prototype = {
    getPrice() {
        return new Error('抽象方法不能调用');
    },
    getSpeed() {
        return new Error('抽象方法不能调用');
    }
};

let BMW = function (price, speed) {
    this.price = price;
    this.speed = speed;
};
VehicleFactory(BMW, 'Car');
BMW.prototype.getPrice = function () {
    return this.price;
};
BMW.prototype.getSpeed = function () {
    return this.speed;
};
let bmw = new BMW(1000000, 200);
console.log(bmw.getPrice(), bmw.getSpeed());